package demo1230.homework;



public class Guke extends Thread{
    private Baozi baoZi;
    public Guke(Baozi baoZi){
        this.baoZi=baoZi;
    }
    @Override
    public void run(){
        while (true){
            synchronized (baoZi){
                if(!baoZi.isZhtai()){
                    try {
                        baoZi.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println("顾客正在吃"+baoZi.getPi()+baoZi.getXian()+"包子,吃了3秒");
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("吃完了");
                baoZi.setZhtai(false);
                baoZi.notify();
            }
        }
    }
}
